﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ChatClient
{
    public partial class View : Form
    {
        ClientModel clients = new ClientModel();
        string historyText;
        string username;
        public View()
        {
            InitializeComponent();
        }

        private void View_Load(object sender, EventArgs e)
        {
            this.history.Width = this.Width - 180;
            this.history.Height = this.Height / 100 * 8;
            history.Left = this.Width - history.Width / 2;
            history.Top = 0;
            message.Width = this.Width - 180;
            message.Left = 90;
            users.Left = 0;
            rooms.Left = this.Width - rooms.Width;
        }

        private void kuld_Click(object sender, EventArgs e)
        {
            clients.sendMsg(message.Text);
            message.Text = "";
        }

        private void message_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                clients.sendMsg(message.Text);
                message.Text = "";
            }
        }

        private void X_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void historyUpdater_Tick(object sender, EventArgs e)
        {
            history.Text = clients.BufferedMsgs();
        }

        private void fun_Click(object sender, EventArgs e)
        {
        }
    }
}
